package model.dao;

import java.sql.PreparedStatement;
import model.Dao;
import model.entity.Controle;


public class ControleDAO extends Dao {

  public static Controle insert_veiculo(Controle car) {
    try {
      PreparedStatement pstmt = getConnection().prepareStatement(
        "Insert Into veiculo(placa, ano_fabricacao, ano_modelo, cor, marca, modelo, proprietario) "
        + "Values(?, ?, ?, ?, ?, ?, ?)");
      pstmt.setObject(1, car.getPLACA());
      pstmt.setObject(2, car.getANO_FABRICACAO());
      pstmt.setObject(3, car.getANO_MODELO());
      pstmt.setObject(4, car.getCOR());
      pstmt.setObject(5, car.getMARCA_DESCRICAO());
      pstmt.setObject(6, car.getMODELO_DESCRICAO());
      pstmt.setObject(7, car.getNOME());
      pstmt.executeUpdate();
      //
      pstmt.close();
    } catch (Exception e) {

    }
    return car;
  }

  public static Controle update(Controle car) {
    try {
      PreparedStatement pstmt = getConnection().prepareStatement(
        "Update Notas Set Nota = ?, Semestre = ?, Materia = ? "
        + "Where id =?");
      pstmt.setObject(1, car.getPLACA());
      pstmt.setObject(2, car.getANO_FABRICACAO());
      pstmt.setObject(3, car.getANO_MODELO());
      pstmt.setObject(4, car.getCOR());
      pstmt.setObject(5, car.getMARCA_DESCRICAO());
      pstmt.setObject(6, car.getMODELO_DESCRICAO());
      pstmt.setObject(7, car.getNOME());
      pstmt.executeUpdate();
      //
     
      pstmt.close();
    } catch (Exception e) {

    }
 return car;
  }
}